package com.gxuwz.service.impl;

import com.gxuwz.dao.UserDao;
import com.gxuwz.entity.User;
import com.gxuwz.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by h on 2017/11/22.
 */
@Service
public class UserService implements IUserService{

    @Autowired
    private UserDao userDao;


    @Override
    public boolean findByUsernameAndPassword(String username, String password) {
        User user = userDao.findByUsernameAndPassword(username,password);
        if(null != user){
            return true;
        }
        return false;
    }

    @Override
    public User save(User user) {
        return userDao.save(user);
    }

    @Override
    public void delete(String id) {
        userDao.delete(Integer.valueOf(id));
    }

    @Override
    public User update(User user) {
        return userDao.save(user);
    }

    @Override
    public User findOne(String id) {
        return userDao.findOne(Integer.valueOf(id));
    }

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }
}
